package com.dyh.lvup.byteBuddy.u2;

import com.dyh.lvup.byteBuddy.Hello;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.FixedValue;

import java.lang.reflect.InvocationTargetException;

import static net.bytebuddy.matcher.ElementMatchers.named;

/*
@Author=Joey Wheeler
@Date=2021/3/3 11:04
*/
public class M {

    public static void main(String[] args) throws IllegalAccessException, InstantiationException, InvocationTargetException {
        OneIntf oneIntf = new ByteBuddy()
        .subclass(OneIntf.class)
        .method(named("oneMethod"))
        .intercept(FixedValue.value("いいよ　こいよ"))
        .make()
        .load(Hello.class.getClassLoader())
        .getLoaded()
        .newInstance();

        System.out.println(oneIntf.oneMethod());
    }
}
